package ar.edu.itba.it.paw.web.converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import ar.edu.itba.it.paw.domain.Question;
import ar.edu.itba.it.paw.repo.impl.HibernateProductRepo;

@Component
public class QuestionConverter implements Converter<String, Question> {

	HibernateProductRepo repository;
	
	@Autowired
	public QuestionConverter(HibernateProductRepo repository){
		this.repository = repository;
	}
	
	@Override
	public Question convert(String string) {
		return repository.getQuestion(Integer.valueOf(string));
	}

}
